
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <style>
            body {
                border: none;
            }
        </style>
    </head>
<body>
    <div class="calculatornav">
        <form class="form-horizontal" id="calculatornavform" role="form" action="<?php echo url_for('tools/calculator')?>" method="POST">
            <div class="form-group">
                <label for="investmentamount" class="col-xs-3 control-label">投资金额</label>
                <div class="col-xs-8">
                    <div class="input-group">
                        <input value="<?php echo $investmentamount?>" type="text" id="investmentamount" name="investmentamount" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"  class="form-control" maxlength="9">
                        <span class="input-group-addon">元</span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label for="yearrate" class="col-xs-3 control-label">年化收益率</label>
                <div class="col-xs-8">
                    <div class="input-group">
                        <input value="<?php echo $yearrate?>" type="text" class="form-control" id="yearrate" name="yearrate" maxlength="4">
                        <span class="input-group-addon">% </span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label for="countdate" class="col-xs-3 control-label">计息时长</label>
                <div class="col-xs-3">
                    <input type="text" value="<?php echo $countdate?>" class="form-control" id="countdate" onkeyup="value=value.replace(/[^\d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))" name="countdate" maxlength="3">
                </div>
                <div class="col-xs-2">
                     <div class="radio">
                        <label>
                            <input <?php if($duration == 2):?>checked="checked"<?php endif;?> id="duration" name="duration" type="radio" value="2" />月
                        </label>
                    </div>
                </div>
                <div class="col-xs-2">
                    <div class="radio">
                        <label>
                            <input <?php if($duration == 1):?>checked="checked"<?php endif;?> id="duration" name="duration" type="radio" value="1" />天
                        </label>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label for="inputPassword3" class="col-xs-3 control-label">还款方式</label>
                <div class="col-xs-8">
                    <select Class="form-control" id="repayment" name="repayment">
                        <option value="1">每月付息，到期还本</option>
                        <option value="2">一次性还本付息</option>
                    </select>
                </div>
            </div>
        </form>
        <hr />
        <div class="interest_result">
            <span class="ft-l">
                <span>本息合计:</span>
                <span class="col">&#165;<?php echo $all;?></span>
            </span>
            <span class="ft-r">
                <span>利息:</span>
                <span class="col">&#165;<?php echo $interest?></span>
            </span>
        </div>
        <button class="btn btn-primary" id="begincalculation">开始计算</button>
    </div>
    <script type="text/javascript">
        $("#begincalculation").click(function() {
            $("#calculatornavform").submit();
        });
        $("input[name='duration']").on('click', function () {
            if ($(this).val() == "1") {
                $("#repayment").html('<option value="2">一次性还本付息</option>');
            } else {
                $("#repayment").html('<option value="1">每月付息，到期还本</option><option value="2">一次性还本付息</option>');
            }
        });
    </script>
</body>
</html>
